<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>vue计算属性</title>
    <script src="js/vue.js"></script>
</head>

<body>
    <div id="app">
        {{msg2}}
        {{add()}}
    </div>
    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                msg: "hello world dear"
            },
            computed: {
                msg2: function () {
                    return this.msg.split(" ").reverse().join("-");
                }
            },
            methods: {
                add() {
                    return this.msg.split(" ").reverse().join("-");
                }
            },
        });
    </script>
</body>

</html>